var pageii = null;
var grid = null;
$(function() {
	grid = lyGrid({
		pagId : 'paging',
		l_column : [ {
			colkey : "pfinishtime",
			name : "日期",
			renderData : function(rowindex, data, rowdata, column) {
				return new Date(data).format("yyyy-MM-dd hh:mm:ss");
			}
		}, {
			colkey : "material_code",
			name : "物料编码"
		}, {
			colkey : "oname",
			name : "物料名称"
		}, {
			colkey : "now_mold_encode",
			name : "模具编码"
		}, {
			colkey : "number",
			name : "产量"
		}, {
			colkey : "packNum",
			name : "每包件数"
		},{
			colkey : "printTotal",
			name : "条形码打印数量"
		}, {
			colkey : "abolishTotal",
			name : "条形码报废数量"
		}, {
			colkey : "balance",
			name : "条形码使用数量"
		}, {
			colkey : "warehouse",
			name : "仓位"
		}, {
			colkey : "printed",
			name : "是否已打印标签",
			renderData : function(rowindex,data, rowdata, column) {
				if (data==0 || data=="0"){
					return "<font color='red'>未打印标签</font>";
				}else{
					return "<font color='blue'>已打印标签</font>";
				}
			}
		} ],
		jsonUrl : rootPath + '/label_print/label_print_findByPage.shtml',
		dymCol : true,
		checkbox : true,
		serNumber : false
	});
	$("#addFun").click("click", function() {
		addAccount();
	});
	$("#search").click("click", function() {//  绑定查询按扭
		var searchParams = $("#searchForm").serializeJson();
		grid.setOptions({
			data : searchParams
		});
	});

});
function addAccount() {
	 var cbox = grid.getSelectedCheckbox();
	 if (cbox.length > 1 || cbox == "") {
		 layer.msg("只能选中一个");
		 return;
	 }
//	 var printed= grid.selectRow()[0].printed;
	 pageii = layer.open({
		title : "打印标签",
		type : 2,
		area : [ "1800px", "100%" ],
		content : rootPath + '/label_print/labelprint_edit.shtml?id=' + cbox
	});
}
